package QueueUse;/*
 *
 *@author:    Xavier
 *@data:      2023 - 08 - 18
 *@time:      14:55
 *
 */

import java.util.LinkedList;
import java.util.Queue;

public class Test {

    public static void main3(String[] args) {
        //双链表实现队列
    }

    public static void main(String[] args) {
        MyQueue myQueue = new MyQueue();
        myQueue.offer(1);
        myQueue.offer(2);
        int val = myQueue.poll();
        System.out.println(val);
        int val2 = myQueue.peek();
        System.out.println(val2);

    }

    public static void main1(String[] args) {
        //单链表实现队列
        //从尾入队 从头出队 均是O(1)
        Queue<Integer> queue = new LinkedList<>();

        //boolean offer(E e)
        //入队列
        queue.offer(1);
        queue.offer(2);
        //offer与add的区别
        //add在空间不够时 会抛出异常
        //offer不会抛出异常

        //E poll()
        //出队列 - 删除 有返回值
        int val = queue.poll();
        System.out.println(val);

        //只是获取 并非删除
        int val2 = queue.peek();
        System.out.println(val2);

        //int size() --  获取队列中有效元素的个数
        //boolean isEmpty() --  检测队列是否为空

    }
}
